<script setup>
import { nextTick, onMounted, ref } from 'vue';

// 1.定义一个ref
const hRef = ref(null)
const iRef = ref(null)

// 方式一
onMounted(() => {
  // console.log(hRef.value)
  // hRef.value.innerText = '呵呵哈哈哈'

  // iRef.value.focus()
})

// 方式二
nextTick(() => {
  // console.log(hRef.value)

  iRef.value.focus()
})

</script>

<template>
  <!-- 2. 绑定ref -->
  <h1 ref="hRef">我是大标题</h1>
  <input ref="iRef" type="text">
</template>

<style scoped></style>
